home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-13 | 9.2 KB | 269 lines | [TEXT/TOPU] |
- % Logic Manager Copyright 1990 by Apple Computer, Inc.
- % Ruben Kleiman (Advanced Technology Group)
-
- % This is the program for the Hick stack written in
- % Logic Manager syntax. It is possible to write this
- % in Edinburgh Prolog and convert it to LM syntax
- % using the Prolog program LMIMCONV. See user
- % guide for instructions on how to use that program.
-
- trait(bud_scales(valvate),bitternut_hickory).
- trait(buds(yellow),bitternut_hickory).
-
- trait(bud_scales(valvate),pecan_hickory).
- trait(buds(brownish),pecan_hickory).
-
- trait(bud_scales(imbricate),pignut_hickory).
- trait(terminal_buds(short),pignut_hickory).
-
- trait(bud_scales(imbricate), mockernut_hickory).
- trait(terminal_buds(large),mockernut_hickory).
- trait(outer_scales(deciduous),mockernut_hickory).
-
- trait(bud_scales(imbricate),shellbark_hickory).
- trait(terminal_buds(large),shellbark_hickory).
- trait(outer_scales(persistent),shellbark_hickory).
- trait(twigs(orange_brown),shellbark_hickory).
-
- trait(bud_scales(imbricate),shagbark_hickory).
- trait(terminal_buds(large),shagbark_hickory).
- trait(outer_scales(persistent),shagbark_hickory).
- trait(twigs(reddish_brown),shagbark_hickory).
-
- rule(id,warm_start).
-
- rule(warm_start,
- and(analyze_chars_traits,
- and(cut,identify_loop))).
-
- rule(identify_loop,
- and(clearWindow(left),
- and(clearWindow(middle),
- and(clearWindow(right),
- and(clearWindow(results),
- and(clearWindow(debug),
- and(obtain_description,
- and(entertain_hypothesis(Identification),
- and(validate(Identification),
- and(report(Identification),
- and(abolish(user_observed,1),
- and(abolish(does_not_hold,1),
- and(abolish(noted,1),
- and(cut,
- and(writeWindow(after,user,'Select action with menu...',nl),
- and(menu(cons(identify,cons(exit,nil)),Choice,exit_choice), final_act(Choice)
- )))))))))))))))).
-
- rule(final_act(identify),
- and(cut, identify_loop)).
- rule(final_act(exit), halt).
-
- rule(analyze_chars_traits,
- and(setof(ChTr, @^(Tree,trait(ChTr,Tree)), CharsTraits),
- and(group_up(CharsTraits, GrChTrs),
- and(setof(Char, @^(L,char_trs(Char,L)), Chars),assertz(characteristics(Chars)))))).
-
- rule(group_up(nil, nil), cut ).
- rule(group_up(L, cons(char_trs(Funct, Args), RestSubGrs)),
- and(=(L, cons(FirstL, RestL)),
- and(functor(FirstL, Funct,1),
- and(strip_group(L, Funct, Args, RemainderL),
- and(assertz(char_trs(Funct, Args)), group_up(RemainderL, RestSubGrs)))))).
-
- rule(strip_group(nil, _, nil, nil), cut).
- rule(strip_group(cons(Entry, RestL), Funct, cons(Arg, Args), RemainderL),
- and(functor(Entry, Funct, 1),
- and(cut,
- and(arg(1, Entry, Arg), strip_group(RestL, Funct, Args, RemainderL))))).
- strip_group(L, _, nil, L).
-
-
- helpText(obtain_description_1,
- 'Descriptors are pairs of the form: Characteristic Attribute. This menu
- lets you first choose a Characteristic. The next menu will let you choose
- an appropriate Attribute. If you have no more descriptors to input, choose
- done').
-
- helpText(obtain_description_2,
- 'Descriptors are pairs of the form: Characteristic Attribute. The previous
- menu let you choose a characteristic. This menu will lets you choose an
- appropriate Attribute').
-
- rule(clearWindow(Win),
- and(list2atom(cons('put empty into field ',cons(Win,nil)), S), sendcardmsg(S) )).
-
- rule(writeWindow(How,Where,What,none),
- and(list2atom(cons('put "',cons(What,cons('" ',cons(How,cons(' field ',cons(Where,nil)))))),S),
- sendcardmsg(S))).
-
- rule(writeWindow(How,Where,What,nl),
- and(list2atom(cons('put "',cons(What,cons('" & return ',cons(How,cons(' field ',cons(Where,nil)))))),S),
- sendcardmsg(S))).
-
- writeWindow(How,Where,nil,list).
- rule(writeWindow(How,Where,cons(First,Rest),list),
- and(writeWindow(How,Where,First,none), writeWindow(after,Where,Rest,list))).
-
- rule(writeWindow(How,Where,What,listnl),
- and(writeWindow(How,Where,What,list),
- and(list2atom(cons('put return after field ',cons(Where,nil)),S), sendcardmsg(S)))).
-
- writeWindow(How,Where,nil,display).
- rule(writeWindow(How,Where,cons(First,Rest),display),
- and(writeWindow(How,Where,First,nl), writeWindow(after,Where,Rest,display))).
-
- rule(menu(Items, Chosen, Help),
- and(helpText(Help, Text),
- and(setglobal(helpText,Text),
- and(quotelist(Items,'"',Quoted),
- and(list2atom(cons('menu ',Quoted),S),
- and(sendcardmsg(S), getglobal(menuChoice,Chosen))))))).
-
- quotelist(nil,QStr,cons('"',nil)).
- rule(quotelist(cons(First,Rest),QStr,cons(QStr,cons(First,RestList))),
- quotelist(Rest,'","',RestList)).
-
- rule(obtain_description,
- and(characteristics(Chars),
- and(writeWindow(into,user,'Characteristic = ',none),
- and(menu(cons(done,Chars), ChosenChar, obtain_description_1),
- and(writeWindow(after,user,ChosenChar,nl),
- and(
- or(and(or(=(ChosenChar,done),=(ChosenChar,$noChoice)),=(Observer_1,done)),
- and(not(or(=(ChosenChar,done),=(ChosenChar,$noChoice))),
- and(writeWindow(after,user,'Attribute = ',none),
- and(char_trs(ChosenChar,Traits),
- and(menu(Traits, ChosenTrait, obtain_description_2),
- and(writeWindow(after,user,ChosenTrait,nl),
- or(and(=(ChosenTrait,$noChoice), =(Observer_1,done)),
- and(not(=(ChosenTrait,$noChoice)),
- univ(Observer_1,cons(ChosenChar, cons(ChosenTrait,nil)))
- ))
- )))))),
- and(equivalent(Observer_1, Observer), dispatch(Observer)))))))).
-
- rule(dispatch(done),cut).
- rule(dispatch(Observation),
- and(asserta(user_observed(Observation)),
- and(writeWindow(after,left,Observation,nl), obtain_description))).
-
-
- rule(entertain_hypothesis(Identification),
- and(user_observed(Characteristic), trait(Characteristic, Identification))).
- rule(entertain_hypothesis(Identification),
- and(user_observed(Characteristic_1),
- and(equivalent(Characteristic_1, Characteristic),trait(Characteristic, Identification)))).
- rule(entertain_hypothesis(Identification),
- and(not(user_observed(_)), trait(_, Identification))).
- rule(entertain_hypothesis(Identification),
- and(user_observed(Characteristic), trait(Characteristic, Identification))).
-
- helpText(exit_choice,'Identify another tree, Exit from the Identification program').
-
- rule(entertain_hypothesis(_),
- and(writeWindow(into,user,'No tree in database with those characteristics',nl),
- and(abolish(user_observed,1),
- and(abolish(does_not_hold,1),
- and(abolish(noted,1),
- and(clearWindow(left),
- and(clearWindow(middle),
- and(clearWindow(right),
- and(writeWindow(after,user,'Select action with menu...',nl),
- and(menu(cons(identify,cons(exit,nil)),Choice,exit_choice), final_act(Choice))))))))))).
-
- rule(observed(X), user_observed(X)).
-
- rule(not_observed(X), does_not_hold(X)).
-
- rule(validate(Identification),
- and(bagof(Attribute, trait(Attribute,Identification), Characterization),
- and(verify(Characterization), cut))).
-
- verify(nil).
- rule(verify(cons(Attribute, Rest_of_Attributes)),
- and(check(Attribute), verify(Rest_of_Attributes))).
-
- rule(check(Attribute),
- and(observed(Attribute),
- and(note_inference(Attribute), cut))).
- rule(check(Attribute),
- and(not_observed(Attribute),
- and(cut,fail))).
- rule(check(Attribute),
- and(ask_about(Attribute),cut)).
-
- rule(note_inference(Attribute),
- and(noted(Attribute),cut)).
- rule(note_inference(Attribute),
- and(assertz(noted(Attribute)), writeWindow(after,right,Attribute,nl))).
-
- helpText(ask_about_attribute,'Validating a conjecture...Choose True if the attribute is present, False if not.').
-
- rule(ask_about(Attribute),
- and(writeWindow(after,user,cons('Is it true that ', cons(Attribute, cons('?',nil))),list),
- and(menu(cons(true,cons(false,nil)),Answer,ask_about_attribute),
- and(cut,
- and(writeWindow(after,user,Answer,nl),act_on(Answer, Attribute)))))).
-
- rule(act_on(true, Attribute),
- and(writeWindow(after,middle,Attribute,nl),
- and(asserta(user_observed(Attribute)), cut))).
- rule(act_on(false, Attribute),
- and(asserta(does_not_hold(Attribute)),
- and(cut,fail))).
-
- rule(report(Identification),
- and(writeWindow(into,user, cons('The tree appears to be a ', cons(Identification,nil)),listnl),
- and(bagof(Characteristic, trait(Characteristic, Identification), Traits),
- writeWindow(into,results, cons('Identifying traits ',Traits),display)
- ))).
-
- rule(observed(outer_scales(X)),
- and(opposite(X,Y), does_not_hold(outer_scales(Y)))).
-
- rule(observed(terminal_buds(X)),
- and(opposite(X,Y), does_not_hold(terminal_buds(Y)))).
-
- rule(observed(bud_scales(X)),
- and(opposite(X,Y), does_not_hold(bud_scales(Y)))).
-
- opposite(short,large).
- opposite(large,short).
- opposite(deciduous,persistent).
- opposite(persistent,deciduous).
- opposite(valvate,imbricate).
- opposite(imbricate,valvate).
-
- rule(observed(outer_scales(X)),
- and(synonymous(X,Y), observed(outer_scales(Y)))).
-
- rule(observed(terminal_buds(X)),
- and(synonymous(X,Y), observed(terminal_buds(Y)))).
-
- rule(observed(bud_scales(X)),
- and(synonymous(X,Y), observed(bud_scales(Y)))).
-
- synonymous(valvate,non_overlapping).
- synonymous(imbricate,overlapping).
- synonymous(short,stout).
-
- rule(not_observed(outer_scales(X)),
- and(opposite(X,Y), user_observed(outer_scales(Y)))).
- rule(not_observed(terminal_buds(X)),
- and(opposite(X,Y), user_observed(terminal_buds(Y)))).
- rule(not_observed(bud_scales(X)),
- and(opposite(X,Y), user_observed(bud_scales(Y)))).
- rule(not_observed(outer_scales(X)),
- and(synonymous(X,Y), not_observed(outer_scales(Y)))).
- rule(not_observed(terminal_buds(X)),
- and(synonymous(X,Y), not_observed(terminal_buds(Y)))).
- rule(not_observed(bud_scales(X)),
- and(synonymous(X,Y), not_observed(bud_scales(Y)))).
-
- rule(equivalent(U,V),
- and(univ(U, cons(P,cons(X,nil))),
- and(synonymous(Y,X),
- and(univ(V, cons(P,cons(Y,nil))), cut)))).
-
- equivalent(U,U).
-